-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
storage/static.go: storage backend should not explicitly lower-case email ids. #1046
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a test and add a docstring to the passwordsByEmail field?
storage/static.go
Outdated
p.Email = strings.ToLower(p.Email) | ||
passwordsByEmail[p.Email] = p | ||
//Enable case insensitive email comparison. | ||
lowerEmail = strings.ToLower(p.Email) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:=
f103da8
to
d0dfe26
Compare
added a test and documentation |
storage/memory/static_test.go
Outdated
if err := s.CreatePassword(p3); err != nil { | ||
return err | ||
} | ||
return s.CreatePassword(p4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to read this value back an ensure the emails match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test makes sure that "[email protected]" cannot be created, so it ensures an error is returned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you want me to check if "[email protected]" gets created with the all lower case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like
p, err := s.GetPassword(strings.ToLower(p4.Email))
p.Email == p4.Email
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
storage/static.go
Outdated
passwordsByEmail[p.Email] = p | ||
//Enable case insensitive email comparison. | ||
lowerEmail := strings.ToLower(p.Email) | ||
passwordsByEmail[lowerEmail] = p |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we log or something if the lowered
email as already in the map?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would just return an error here. @rithujohn191 what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I only think we can log this error. Erroring out would be backward incompatible, if sensible :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if we don't error out we essentially allow the user to overwrite the map. For the following ConfigMap:
staticPasswords:
- email: "[email protected]"
# bcrypt hash of the string "password"
hash: "$2a$10$2b2cU8CPhOTaGrs1HRQuAueS7JTT5ZHsHSzYiFPm1leZck7Mc8T4W"
username: "admin"
userID: "08a8684b-db88-4b73-90a9-3cd1661f5466"
- email: "[email protected]"
# bcrypt hash of the string "password"
hash: "$2a$10$2b2cU8CPhOTaGrs1HRQuAueS7JTT5ZHsHSzYiFPm1leZck7Mc8T4W"
username: "Admin"
userID: "08a8684b-db88-4b73-90a9-3cd1661f5466"
Only the second password gets registered. And then if the user tries to login with the first email it still succeed but returns the wrong email id in the claims:
"email": "[email protected]",
That's not desirable behavior :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rithujohn191 right, but prior to this that config would not have errored, if we error now we might break someone during a dex upgrade.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logged the error
d0dfe26
to
294462e
Compare
working on adding the logger |
294462e
to
fd4f57b
Compare
Done :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
storage/static.go: storage backend should not explicitly lower-case email ids.
No description provided.